//
//  UserProductTableViewCell.m
//  littleLight's Project-A
//
//  Created by dllo on 16/5/24.
//  Copyright © 2016年 light. All rights reserved.
//

#import "UserProductTableViewCell.h"
#import <UIImageView+WebCache.h>
@implementation UserProductTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createView];
        
    }
    return self;
}

- (void)createView
{
    self.title_page = [[UIImageView alloc] init];
    [self.contentView addSubview: self.title_page];
    
    self.title = [[UILabel alloc] init];
    self.title.font = [UIFont systemFontOfSize:20];
    self.title.font = [UIFont boldSystemFontOfSize:18];
    self.title.numberOfLines = 0;
    [self.contentView addSubview: self.title];
    
    self.address = [[UILabel alloc] init];
    self.address.textColor = [UIColor grayColor];
    self.address.font = [UIFont systemFontOfSize:14];
    [self.contentView addSubview: self.address];

    self.sold_count = [[UILabel alloc] init];
    self.sold_count.textColor = [UIColor whiteColor];
    self.sold_count.font = [UIFont systemFontOfSize:14];
    [self.contentView addSubview:self.sold_count];
    
    
    self.labelOne = [[UILabel alloc] init];
    self.labelOne.textColor = [UIColor grayColor];
    self.labelOne.font = [UIFont systemFontOfSize:14];
    [self.contentView addSubview: self.labelOne];
    
    self.labelTwo = [[UILabel alloc] init];
    self.labelTwo.textColor = [UIColor grayColor];
    self.labelTwo.font = [UIFont systemFontOfSize:14];
    [self.contentView addSubview: self.labelTwo];
    
    self.labelThree = [[UILabel alloc] init];
    self.labelThree.textColor = [UIColor grayColor];
    self.labelThree.font = [UIFont systemFontOfSize:14];
    [self.contentView addSubview: self.labelThree];
    
    self.discount_price = [[UILabel alloc] init];
    self.discount_price.font = [UIFont systemFontOfSize:23];
    self.discount_price.textColor = [UIColor colorWithRed:1.0 green:94 / 255.0 blue:35 / 255.0 alpha:1];
    self.discount_price.font = [UIFont boldSystemFontOfSize:21];
    [self.contentView addSubview:self.discount_price];
}





- (void)layoutSubviews
{
    [super layoutSubviews];
    self.title_page.frame = CGRectMake(5, 5, self.contentView.frame.size.width - 10, self.contentView.frame.size.height / 7 * 4);
    self.title.frame = CGRectMake(10, self.title_page.frame.size.height + 5, self.frame.size.width / 10 * 7, self.contentView.frame.size.height / 7);
    
    self.address.frame = CGRectMake(self.title.frame.origin.x, self.contentView.frame.size.height / 7 * 5 + 5, self.contentView.frame.size.width / 4 * 3, 40);
    
    self.sold_count.frame = CGRectMake(self.contentView.frame.size.width / 4 * 3, self.title_page.frame.size.height - 70, 70, 30);
    
    self.labelOne.frame = CGRectMake(self.title.frame.origin.x, self.contentView.frame.size.height / 7 * 6 - 5, 60, 40);
    self.labelTwo.frame = CGRectMake(self.title.frame.origin.x + 70, self.contentView.frame.size.height / 7 * 6 - 5, 60, 40);
    self.labelThree.frame = CGRectMake(self.title.frame.origin.x + 130, self.contentView.frame.size.height / 7 * 6 - 5, 60, 40);
    self.discount_price.frame = CGRectMake(self.contentView.frame.size.width / 4 * 3, self.contentView.frame.size.height / 7 * 6 - 5, 80, 50);
    
}

- (void)setModel:(CityPageModel *)model
{
    _model = model;
    
    self.sold_count.text = [NSString stringWithFormat:@"%@人体验过",_model.sold_count];
    
    
    [self.title_page sd_setImageWithURL:[NSURL URLWithString:_model.title_page]];
    self.title.text = _model.title;
    
   
    NSString *string1 = _model.address;
    NSString *string2 = [NSString stringWithFormat:@"%@人喜欢",[_model.like_count stringValue]];
    NSString *string3 = _model.date_str;
    
    self.address.text = [NSString stringWithFormat:@"· %@ %@· %@",string1,string3,string2];
    if (model.tab_list.count == 1) {
        self.labelOne.text = model.tab_list[0];
      //  self.labelTwo.text = nil;
      //  self.labelTwo.text = nil;
        
    }
    if (model.tab_list.count == 2) {
        self.labelOne.text = model.tab_list[0];
        self.labelTwo.text = model.tab_list[1];
        
    }
    if (model.tab_list.count == 3) {
        self.labelOne.text = model.tab_list[0];
        self.labelTwo.text = model.tab_list[1];
        self.labelThree.text = model.tab_list[2];
    }
    
    if ([_model.discount_price isEqualToString:@""]) {
        _model.discount_price = _model.price;
        self.discount_price.text =[NSString stringWithFormat:@"￥%@",_model.discount_price];
    }else{
        self.discount_price.text =[NSString stringWithFormat:@"￥%@",_model.discount_price];
        
    }
    

    
}







@end
